﻿
function loadPage(counter) {
    $.ajax({
        url: "http://localhost:2663/api/ScrilableEnities?counter=" + counter + "&itemsCount=" + items,
        type: "GET",
        contentType: "application/json"
    }).done(function (data) {
        $("#list").html("");
        for (var i = 0; i < data.length; i++) {
            $("#list").append("<li><span> ID : " + data[i].id + "</span><span> " + data[i].content + "</span> </li>");
        }

        console.log("counter : " + counter);
    });
}

var counter = 0;
var items = 10;

loadPage(counter);

$("#itemsOnPage").append("<span>" + items + "</span>");

$("#forward").on("click", function () {
    if (counter < 0) {
        counter = items;
        return;
    }
    counter = counter + items;
    loadPage(counter);
});

$("#backward").on("click", function () {
    
    if (counter < 0) {
        counter = items;
        return;
    }
    counter = counter - items;
    loadPage(counter);
});










